﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace TestApplicationObjects
{
    public static class StringExtentions
    {
        public static bool HasNumbers(this string testValue)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(testValue, @"\d+");
        }

        public static string RightString(this string value, int characters)
        {
            return value.Substring(value.Length - characters, characters);
        }

        public static List<string> AsListOfValues(this string str)
        {
            //List<string> items = new List<string>();
            if (str == null)
                return new List<string>();
            var data = str.Split(new[] { ",", Environment.NewLine, "\r", "\n", "\r\n", "\n\r" }, StringSplitOptions.RemoveEmptyEntries).
                            Select(
                            s => HttpUtility.HtmlEncode(s).Replace(Environment.NewLine, "").Trim().ToLower()).Where(s => s.Length > 1).ToList();
            return data;

        }
    }
}
